package everyday;

/**
 * @author 兴趣使然黄小黄
 * @version 1.0
 * @date 2023/6/25 1:18
 * 551. 学生出勤记录
 * https://leetcode.cn/problems/student-attendance-record-i/
 */
public class Solution551 {

    public boolean checkRecord(String s) {
        int absentDays = 0;  // 记录缺勤天数
        int lateDays = 0;  // 记录连续缺勤的天数
        for (char c : s.toCharArray()) {
            if (c == 'L') {
                ++lateDays;
            } else {
                lateDays = 0;
                if (c == 'A') {
                    ++absentDays;
                }
            }
            if (lateDays >= 3 || absentDays >= 2) {
                return false;
            }
        }
        return true;
    }
}
